<?php

namespace app\models;

use Yii;
use yii\db\ActiveRecord;

class topicState extends ActiveRecord{
      public static function tableName(){
	        return "{{%topicState}}";
                }

      public function add($data){
             if($data){
                $this->topicId = $data['topicId'];
                $this->openid = $data['openid'];
                $this->state = $data['state'];
                $result = $this->save();
                if($result){
                     $error = 0;
                     return $error;
                 }else{
                     $error = $this->getErrors();
                     return $error ;
                    }
                 }else {
                     $error = 2;
                     return $error;
               }
          }
     }
